<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
         
        class Phone {
            //当对price属性进行读取就会执行该函数
            get price() {
                console.log('价格被读取了')
                return 'price'
            }
            //设置price的值时就会执行该函数
            set price (newVal) {
                console.log('价格属性被修改了')
            }
        }


        const s = new Phone()
        console.log(s.price)
        s.price = 'free'












    </script>
</body>
</html>